package com.geotmt.billingcenter.modules.rules.mapper.provider;

import com.geotmt.billingcenter.common.entry.StairRule;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Description 计费规则SQL类
 * @Author      yanghanwei
 * @Mail        yanghanwei@geotmt.com
 * @Date        2019/3/25 17:34
 * @Version     v1
 **/
public class RulesProvider {

    private static final Logger logger = LoggerFactory.getLogger(RulesProvider.class);

    /**
     * 添加阶梯计费规则
     * @param stairRule
     * @return
     */
    public String addStair(StairRule stairRule){
        StringBuffer sql = new StringBuffer();
        sql.append("INSERT INTO fin_stair_rule (r_id,label,min,max,price) VALUES (#{rId},#{label},#{min},#{max},#{price})");
        logger.info("addStair SQL:{}",sql);
        return sql.toString();
    }


    /**
     * getList
     * @param rId
     * @param label
     * @return
     */
    public String stairListGetByRid(@Param(value = "rId") Integer rId,
                                    @Param(value = "label") Integer label){
        StringBuffer sql = new StringBuffer();
        sql.append("SELECT id,r_id rId,label,`min`,`max`,price FROM fin_stair_rule WHERE r_id=#{rId} AND label=#{label} ORDER BY `min` ASC");
        logger.info("stairListGetByRid SQL:{}",sql);
        return sql.toString();
    }
}
